global infile "DataMain.dta"
global outfile "$results\Table 8"


* Create monthly data and post dummies

use "$infile", clear

egen watermonth = mean(water), by(home month)
gen logwatermonth = log(watermonth+1)
gen logwatermonth0 = log(watermonth)
gen dwatermonth = (watermonth != 0)
replace water = watermonth
replace logwater = logwatermonth
replace logwater0 = logwatermonth0
replace dwater = dwatermonth
duplicates drop home year month, force

forvalues i = 1(1)12 {
	gen treatmoy`i' = (moy == `i' & treat == 1)
}
gen post = 0
replace post = 1 if week >= 0 & weeksDD == 1
replace post = 1 if week2 >= 0 & weeksDD == 2
egen datasetpost = group(dataset post)


* Table 8. Month-of-year specific estimates

reghdfe logwater treatmoy1-treatmoy12 i.moy, absorb(datasethome datasetpost) cluster(home)
outreg2 using "$outfile", nocon 2aster dec(3) word replace

reghdfe logwater0 treatmoy1-treatmoy12 i.moy, absorb(datasethome datasetpost) cluster(home)
outreg2 using "$outfile", nocon 2aster dec(3) word ap

reghdfe dwater treatmoy1-treatmoy12 i.moy, absorb(datasethome datasetpost) cluster(home)
outreg2 using "$outfile", nocon 2aster dec(3) word ap
